using System.Collections.Generic;
using WCell.Constants.GameObjects;
using WCell.Constants.World;
using WCell.Core.Initialization;
using WCell.RealmServer.Entities;
using WCell.RealmServer.GameObjects;
using WCell.RealmServer.Global;
using WCell.Util.Graphics;

namespace Kingdoms
{
    public abstract class TerritoryTemplate
    {
        private List<ZoneInfo> _infos = new List<ZoneInfo>();
        private List<Zone> _zones = new List<Zone>();
        private MapId _mapId;
        public List<Territory> NeighboringTerritories = new List<Territory>();

        public GOEntryId Flag;

        public float UpgradeTimeGuardCount = 600f;
        public float UpgradeTimeExperienceLevel = 600f;
        public float UpgradeTimeTrainingLevel = 600f;

        public int UpgradeGuardCountCostPercent = 25;
        public int UpgradeTrainingLevelCost = 10;
        public int UpgradeExperienceLevelCost = 10;

        public TerritoryTemplate(MapId mapId, GOEntryId flag)
        {
            foreach(var zone in Zones)
            {
                _infos.Add(zone.Info);
            }
            _mapId = mapId;
            Flag = flag;
        }
        
        public abstract int Id
        { 
            get;
        }

        /// <summary>
        /// Subzones. Add in the constructor
        /// </summary>
        public List<Zone> Zones
        {
            get { return _zones; }
        }

        /// <summary>
        /// The ZoneInfos of all the subzones
        /// </summary>
        public List<ZoneInfo> ZoneInfos
        {
            get { return _infos; }
        }

        /// <summary>
        /// The position of the flag.
        /// </summary>
        public abstract Vector3 FlagPosition
        { 
            get;
        }

        public abstract string Name
        {
            get;
        }

        /// <summary>
        /// Whether an area is open, which means it can be capped without owning neighboring territories
        /// </summary>
        public abstract bool IsOpen
        {
            get;
        }

        /// <summary>
        /// The region we belong to
        /// </summary>

        public Region Region
        {
            get { return World.GetRegion(_mapId); }
        }
        
        /// <summary>
        /// Fixing/setting up of all GOs takes place here.
        /// </summary>

        public virtual void FixGOs()
        {
        }
    }
}